var reviveCount = 5;
var mapIds = [867110050, 867110100, 867110150, 867110200, 867110250, 867110300, 867110350, 867110400, 867110450, 867110500, 867110550, 867110600, 867110650, 867110700];
var 准备地图 = 867110001;
var eventName = "副本_APORD飞船";

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(eventName);
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(false)
    }
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(3 * 60 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    em.setProperty("kill", "0");
    if (a == 867110500) {
        em.setProperty("clear", "1")
    } else {
        em.setProperty("clear", "0")
    }
    em.setProperty("curMap", a);
    em.setProperty("嘟嘟", "0")
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(c, e) {
    var b = player.getMapId();
    if (b == 867110600 || b == 867110650) {
        var f = 1
    } else {
        if (b == 867110700) {
            var f = 2
        } else {
            var f = 11
        }
    }
    var a = em.getNumberProperty("kill") + 1;
    em.setProperty("kill", a);
    var d = em.getNumberProperty("expCount") + Math.round(Math.pow(player.getLevel(), 2.5));
    em.setProperty("expCount", d);
    player.getAPI().getMap().getWeatherEffectNotice("经验值奖励累积 " + player.getAPI().formatNumberWithComma(d) + " !", 217, 5000, 1);
    c.getPlayers().forEach(function (h) {
        h.getAPI().setNumberForQuestInfo(59792, "expCount", d);
        h.getAPI().setNumberForQuestInfo(63864, "expCountEv", d);
        if (e == 9410856) {
            h.getAPI().addNumberForQuestInfo(59785, "f", 1)
        } else {
            if (e == 9410851) {
                h.getAPI().addNumberForQuestInfo(59785, "t", 1)
            } else {
                if (e == 9410853 || e == 9410854) {
                    h.getAPI().addNumberForQuestInfo(59785, "c", 1)
                } else {
                    if (e == 9410855) {
                        h.getAPI().addNumberForQuestInfo(59785, "ac", 1)
                    } else {
                        if (e == 9410857) {
                            h.getAPI().addNumberForQuestInfo(59785, "af", 1)
                        } else {
                            if (e == 9410852) {
                                h.getAPI().addNumberForQuestInfo(59785, "at", 1)
                            } else {
                                if (e == 9410858 || e == 9410859) {
                                    h.getAPI().addNumberForQuestInfo(59785, "h", 1)
                                } else {
                                    if (e == 9410860) {
                                        h.getAPI().addNumberForQuestInfo(59785, "ah", 1)
                                    } else {
                                        if (e == 9410856) {
                                            h.getAPI().addNumberForQuestInfo(59785, "f", 1)
                                        } else {
                                            if (e == 9410821 || e == 9410825 || e == 9410832) {
                                                h.getAPI().addNumberForQuestInfo(59600, "59600_1", 1);
                                                h.getAPI().addNumberForQuestInfo(59600, "59600_2", 1);
                                                h.getAPI().addNumberForQuestInfo(59600, "59600_3", 1);
                                                if (parseInt(em.getProperty("嘟嘟")) == 1) {
                                                    h.getAPI().addNumberForQuestInfo(59640, "59640_1", 1);
                                                    h.getAPI().addNumberForQuestInfo(59640, "59640_2", 1);
                                                    h.getAPI().addNumberForQuestInfo(59640, "59640_3", 1)
                                                }
                                            } else {
                                                if (e == 9410801 || e == 9410811 || mob == 9410831) {
                                                    h.getAPI().addNumberForQuestInfo(59620, "59620_1", 1);
                                                    h.getAPI().addNumberForQuestInfo(59620, "59620_2", 1);
                                                    h.getAPI().addNumberForQuestInfo(59620, "59620_3", 1);
                                                    h.getAPI().addNumberForQuestInfo(59620, "59620_4", 1);
                                                    em.setProperty("嘟嘟", "1")
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (a == f) {
            if (h.getAPI().isLeader()) {
                h.getMap().getAllMonsters().forEach(function (i) {
                    if (i.getId() != 9410883) {
                        h.getMap().killMonster(e)
                    }
                });
                var g = h.getMapId();
                if (g == 867110150 || g == 867110350 || g == 867110600 || g == 867110650) {
                    h.getAPI().spawnMobLimit(9410881, 1, 0, 116, 1)
                } else {
                    h.getAPI().spawnMobLimit(9410881, 1, 0, 46, 1)
                }
                c.schedule("清图", 1800);
                c.schedule("结束特效", 3000)
            }
            h.getAPI().fieldEffect_复合图片动画(["Map/EffectPL.img/3min/clearS/skeleton_clear", "animation_text01_01", "", ""], [0, 0, 1, 0, 0, 0, 0, 0]);
            h.getAPI().fieldEffect_PlayFieldSound("Party1/Clear");
            if (g == 867110700) {
                h.getAPI().addNumberForQuestInfo(59640, "59640_1", 1);
                h.getAPI().addNumberForQuestInfo(59640, "59640_2", 1)
            }
        }
    })
}

function 清图() {
    var a = parseInt(em.getProperty("curMap"));
    eim.getMapInstance(a).killMonster(9410883)
}

function 结束特效() {
    em.setProperty("clear", "1");
    eim.getPlayers().forEach(function (a) {
        a.getAPI().playerMessage(-1, "已达到关卡目标。为了进行下个关卡，请使用传送口。");
        a.getAPI().openNpc(2540005, "APORD飞船_通关")
    })
}

function 刷怪() {
    var a = em.getNumberProperty("curMap");
    var c = eim.getMapInstance(a);
    var b = em.getNumberProperty("mob");
    switch (b) {
        case 1:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(0, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(550, 116));
            break;
        case 2:
        case 3:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(-550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(-440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(-220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(-110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(0, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(550, 116));
            break;
        case 4:
        case 5:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410858), new java.awt.Point(-550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(-440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410860), new java.awt.Point(-220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(-110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410858), new java.awt.Point(0, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410860), new java.awt.Point(110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410860), new java.awt.Point(220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410858), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410858), new java.awt.Point(550, 116));
            break;
        case 6:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(-110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(0, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410850), new java.awt.Point(550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410852), new java.awt.Point(0, 116));
            break;
        case 7:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(-550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410858), new java.awt.Point(-220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410860), new java.awt.Point(-110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(0, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410860), new java.awt.Point(110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410858), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410859), new java.awt.Point(550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410855), new java.awt.Point(0, 116));
            break;
        case 8:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(-550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(-220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(-110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(0, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410854), new java.awt.Point(110, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(220, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(440, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410853), new java.awt.Point(550, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410857), new java.awt.Point(0, 116));
            break
    }
    switch (a) {
        case 867110100:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410865), new java.awt.Point(0, -338));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410864), new java.awt.Point(720, -488));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410863), new java.awt.Point(-720, -488));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410863), new java.awt.Point(-810, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410863), new java.awt.Point(810, 116));
            break;
        case 867110150:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410868), new java.awt.Point(0, 116));
            break;
        case 867110200:
            break;
        case 867110250:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410870), new java.awt.Point(0, 46));
            break;
        case 867110300:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410871), new java.awt.Point(0, 46));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410872), new java.awt.Point(0, 46));
            break;
        case 867110350:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(30, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-30, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(90, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-90, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(150, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-150, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(210, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-210, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(270, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-270, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-330, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(390, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-390, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(450, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-450, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(510, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-510, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(570, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-570, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(630, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-630, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(690, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-690, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(750, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(-750, 116));
            c.spawnMonsterOnGroundBelow(em.getMonster(9410869), new java.awt.Point(810, 116));
            break;
        case 867110400:
            break;
        case 867110450:
            c.spawnMonsterOnGroundBelow(em.getMonster(9410877), new java.awt.Point(0, 46));
            break
    }
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function onItemPickedUp(a) {}

function onMonsterDamaged(a) {};